﻿@model IEnumerable<MatchSummaryViewModel>

@{ ViewBag.Title = "Approve matches"; }

<section>
    <div class="k-block grid_12 clearfix" id="approveMatch">

        <div class="k-header k-state-selected">@ViewBag.Title</div>

        @(Html.Kendo().Grid(Model)
            .Name("matchSearchResultsGrid")
            .Columns(columns =>
            {
                columns.Bound(item => item.MatchDate);
                columns.Bound(item => item.CompetitionName);
                columns.Bound(item => item.VenueName);
                columns.Bound(item => item.Team1Name);
                columns.Bound(item => item.FullTimeScore);
                columns.Bound(item => item.Team2Name);
                columns.Template(@<text>
                      @if (item.IsApproved)
                      {
                          <img src="~/Content/images/tick.png" height="18" />
                      }
                      else 
                      {
                          <img src="~/Content/images/cross.png" height="18" />
                      }
                      </text>).Title("Approved");
                columns.Template(@<text>

                    @if(item.CanApprove)
                    {
                    <span>@Html.ActionLink("Approve", "ConfirmApproval", "Edit", new { id = item.MatchGuid }, new { onclick = "return confirm('Are you sure?');" })</span>
                    }

                </text>).Title("Action");

              })
              .Sortable() 
              .DataSource(dataSource => dataSource
                  .Server()
                  .Model(model => model.Id(product => product.MatchGuid))
              )
        )

    </div>
</section>